import instance from '@/utils/request'
//管理员登录
export const adminLoginService = (obj) => {
  return instance.post('/admin/login', {
    ...obj
  })
}

//获取专家列表
export const adminGetExpertListService = (obj) => {
  return instance.get('/admin/pageExpert', {
    params: {
      ...obj
    }
  })
}
//获取详细专家信息
export const adminGetExpertDetailService = (userId) => {
  return instance.get(`/admin/expertDetail/${userId}`)
}

//删除专家信息
export const adminDeleteExpertService = (userId) => {
  return instance.delete(`/admin/deleteExpert/${userId}`)
}

//删除专家图片
export const adminDeleteExpertAvatarService = (userId) => {
  return instance.delete(`/admin/deleteImage/${userId}`)
}

//上传专家或意向专家图片
export const adminUploadExpertAvatarService = (data, type) => {
  return instance.post('/common/upload', data, {
    params: {
      type
    }
  })
}

//修改专家信息
export const adminUpdateExpertService = (obj) => {
  const { oldUserId, ...body } = obj
  return instance.put('/admin/update/expert', body, {
    params: { oldUserId }
  })
}

//修改专家文档
export const adminUpdateInfoMdService = (userId, markdownContent) => {
  return instance.put('/admin/update/expertMark', {
    userId,
    markdownContent
  })
}

//重置专家密码
export const adminResetExpertPasswordService = (userId) => {
  return instance.put('/admin/rest/expertPassword', null, {
    params: {
      userId
    }
  })
}

//添加专家
export const adminAddExpertService = (obj) => {
  return instance.post('/admin/addExpert', null, {
    params: {
      ...obj
    }
  })
}

//获取意向专家列表
export const adminGetPotExpertListService = (obj) => {
  return instance.get('/admin/pageIntentional', {
    params: {
      ...obj
    }
  })
}

//获取详细意向专家信息
export const adminGetPotExpertDetailService = (userId) => {
  return instance.get(`/admin/intentionalDetail/${userId}`)
}

//修改意向专家文档

export const adminUpdatePotInfoMdService = (userId, markdownContent) => {
  return instance.put('/admin/update/intentionMark', {
    userId,
    markdownContent
  })
}

//删除意向专家信息
export const adminDeletePotExpertService = (userId) => {
  return instance.delete(`/admin/deleteIntentionalExpert/${userId}`)
}

// //删除意向专家图片
// export const adminDeletePotExpertAvatarService = userId =>{
//   return instance.delete(`/admin/deleteImage/${userId}`)
// }

// //修改专家信息
// export const adminUpdateExpertService = obj =>{
//   const { oldUserId, ...body } = obj
//   return instance.put('/admin/update/expert', body, {
//     params: { oldUserId }
//   })
// }

// //重置专家密码
// export const adminResetExpertPasswordService = userId =>{
//   return instance.put('/admin/rest/expertPassword',null,{
//     params:{
//       userId
//     }
//   })
// }

//添加意向专家
export const adminAddPotExpertService = (obj) => {
  const { password, ...obj1 } = obj
  return instance.post('/admin/addIntentional', null, {
    params: {
      ...obj1
    }
  })
}

//同意意向专家入库
export const adminAgreePotExpertService = (intentionalId) => {
  return instance.post(`/admin/agreeToExpert/${intentionalId}`)
}

//获得管理员信息
export const adminGetAdminInfoService = () => {
  return instance.get('/admin/getManageDetail')
}

//修改管理员信息
export const adminUpdateAdminInfoService = ({ manageId, username }) => {
  return instance.put('/admin/updateManager', {
    manageId,
    username
  })
}

//修改管理员密码
export const adminUpdatePasswordService = ({ oldPassword, newPassword }) => {
  return instance.put('/admin/updatePassword', null, {
    params: {
      oldPassword,
      newPassword
    }
  })
}

//添加管理员
export const adminAddAdminService = ({ manageId, username, password }) => {
  return instance.post('/admin/addManager', {
    manageId,
    username,
    password
  })
}
